<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include("ListResult.php");
$strSQL = $strSQL." order by ID limit ".(($intPageNow-1)*$intPageNo).",".$intPageNo." ";

if(!$RS = mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Lotto Data Error!!";
	$GLOBALS["errorhidden"] = "\n Error: ".mysql_error($$_Conn).",\nSQL: ".$strSQL.",\nLine: ".__LINE__.",\nPage: ".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}

$fp = @file($strTemplatePath."List.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

while(list($k, $v) = each($_strLotto)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

$strCon = "";
//分頁下拉清單
for($i = 1; $i <= $intTotalPage; $i++){
	if($i == $intPageNow){
		$strCon .= "<option value='".$i."' selected>".$i."</option>\n";
	}else{
		$strCon .= "<option value='".$i."'>".$i."</option>\n";
	}
}
$fp = str_replace("{PageSelectOpion}", $strCon, $fp);
$fp = str_replace("{intTotalPage}", $intTotalPage, $fp);
$fp = str_replace("{intPageNow}", $intPageNow, $fp);
$fp = str_replace("{intTotal}", $intTotal, $fp);

//內容清單
$strCon = "";
$strTmp = "";
$intSum = 0;
preg_match("/<!-- @ Content Start @ \/\/-->(.+)<!-- @ Content End @ \/\/-->/s", $fp, $arrMatch);

$arrLottoPower = getLottoUsePowerArray();
while($objLotto = PMA_mysql_fetch_object($RS)){
	if(!in_array($objLotto -> ID, $arrLottoPower))continue;

	$strTmp = $arrMatch[1];
	$strLotto = "Lotto_".$_intLang;

	$strTmp = str_replace("{ShowID}", $objLotto -> ID, $strTmp);
	$strTmp = str_replace("{ShowLotto}", $objLotto -> $strLotto, $strTmp);
	$strTmp = str_replace("{ShowLType}", $_arrLType[$objLotto -> LType], $strTmp);
	$strTmp = str_replace("{ShowLottoURL}", $objLotto -> LottoURL, $strTmp);
	$strTmp = str_replace("{ShowNumber}", str_replace("0,", "0,<br />", $objLotto -> Number), $strTmp);
	if($objLotto -> LType != 1)$strTmp= preg_replace("/<!-- @ Animals Start @ \/\/-->.+<!-- @ Animals End @ \/\/-->/s", "&nbsp;", $strTmp);
	if(!$_arrPermitChRate[$objLotto -> LType])$strTmp= preg_replace("/<!-- @ ChRate Start @ \/\/-->.+<!-- @ ChRate End @ \/\/-->/s", "&nbsp;", $strTmp);
	if(!$_arrPermitTimeItems[$objLotto -> ID])$strTmp= preg_replace("/<!-- @ TimeItems Start @ \/\/-->.+<!-- @ TimeItems End @ \/\/-->/s", "&nbsp;", $strTmp);

	$strCon .= $strTmp."\n";
	$intSum++;
} //while($objLotto = mysql_fetch_object($RS)){
$fp = str_replace("{Sum_MNo}", $intSum, $fp);
$fp = preg_replace("/<!-- @ Content Start @ \/\/-->.+<!-- @ Content End @ \/\/-->/s", $strCon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>